package com.example.a17376046_xsh_finaltest.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.Spinner;

import com.example.a17376046_xsh_finaltest.R;
import com.example.a17376046_xsh_finaltest.adapter.DynamicAdapter;
import com.example.a17376046_xsh_finaltest.entity.Dynamic;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class DynamicFragment extends Fragment {
    ListView listview;
    Dynamic yingyangcang, yundong, xueya, xingtiao;
    List<Dynamic> mList;
    Dynamic xsh2,xsh1,xsh3,xsh4,xsg5;
    Spinner mSpinner;
    int imagePos = 0;
    List<Map<String, Object>> imageList;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View view = inflater.inflate(R.layout.fragment_dynamic_item, null);
        initView(view);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);
        setAdapter();
        registerForContextMenu(listview);
    }

    private void setAdapter() {
        // TODO Auto-generated method stub
        DynamicAdapter ma = new DynamicAdapter(getData(), getActivity());
        listview.setAdapter(ma);
    }

    private List<Dynamic> getData() {
        mList = new ArrayList<Dynamic>();
        xsh1=new Dynamic(R.mipmap.tou1,"狼头","2019-6-13","发布了一张图片",R.mipmap.f);
        xsh2=new Dynamic(R.mipmap.tou2,"亭子","2019-6-13","发布了一张图片",R.mipmap.ff);
        xsh3=new Dynamic(R.mipmap.tou2,"亭子","2019-6-13","发布了一张图片",R.mipmap.pn);
        xsh4=new Dynamic(R.mipmap.tou2,"亭子","2019-6-13","发布了一张图片",R.mipmap.xx);
        mList.add(xsh1);
        mList.add(xsh2);
        mList.add(xsh3);
        mList.add(xsh4);
        return mList;
    }

    private void initView(View view) {
        listview =view.findViewById(R.id.list_dynamic);
    }
}
